function ProdGener($,com){
	return {
		// 产片描述
		prdRemark:function(container,desList,pics,lgPath){
			function prdRmkPics(pics){
				var html ="<div class='rmkcon' cur='1' total='" + pics.length + "'>";
				html +=   	"<div class='dir leftdir' tg='-1' ></div>";
				html += 	"<div class='items'>";
				html += 	"	<div class='items-cover' style='width:" + pics.length*100 + "px'>";
				$(pics).each(function(){
					html += "<div class='item'><img src='" +  lgPath + this.reserve5 + "' ></div>";
				});
				html += '	</div>';
				html += '</div>';
				html += "<div class='dir rightdir' tg='1'></div>";
				html += '</div>';
				html += '</div>';
				return html;
			}

			var html = "";
			var trs = "";
			html +='<div class="search-con-item">';
			html +='	<div class="search-con-item-title">产品描述</div>';
			html +='	<div class="dk-table product-desc">';
			html +='	  <table>';
			html +='		<thead>';
			html +='		<th>产品名称</th>';
			html +='		<th>产品编号</th>';
			html +='		<th>产品系列</th>';
			html +='		<th>德科号</th>';
			html +='		<th>产品图片</th>';
			html +='		</thead>';
			html +='		<tbody>';
			$(desList).each(function(){
				trs += "<tr>";
				trs += "<td>" + this.reserve1 +"</td>";
				trs += "<td>" + this.reserve2 +"</td>";
				trs += "<td>" + this.reserve4 +"</td>";
				trs += "<td>" + this.reserve3 +"</td>";
				trs += "<td style='position:relative;'>" + prdRmkPics(pics) +  "</td>";
				trs += "</tr>";
			});
			html += trs;
			html +='		</tbody>';
			html +='	  </table>';
			html +='	</div>';
			html +='</div>';
			$(container).append(html);
			$(".rmkcon").find(".dir").on("click",function(){
				var tg = $(this).attr("tg");
				var cur = parseInt($(this).parent().attr("cur"));
				var total = $(this).parent().attr("total");
				if(total == "1"){
					return;
				}
				if(tg == "-1"){
					if(cur == 1){
						return;
					}else{
						cur = cur -1;
						 $(this).parent().attr("cur",cur);
						$(this).parent().find(".items-cover").css({"left": -1 * (cur -1) * 100});	 
					}
				}else{
					
					if(cur == total){
						return;
					}else{
						cur = cur + 1;
						$(this).parent().attr("cur",cur);
						$(this).parent().find(".items-cover").css({"left": -1 * (cur-1) * 100});	
					}
				}
			});
		},
		// 参数信息
		paramInfo:function(container,partList){
			var html = "";
			html +='<div class="search-con-item">';
			html +='	<div class="search-con-item-title">参数信息</div>';
			html +='	<div class="dk-table param" >';
			html +='	  <table>';
			html +='		<tbody>';
			var trs = "";
			$(partList).each(function(){
				trs += "<tr>";
				trs += "<td>" + this.brandName + "</td>";
				trs += "<td>" + this.modelName + "</td>";
				trs += "</tr>";
			});
			html += trs;
			html +='		</tbody>';
			html +='	  </table>';
			html +='	</div>';
			html +='</div>';
			$(container).append(html);
		},
		// 适配车型
		carInfo:function(container,vehicles){
			var trs = "";
			var html = "";
			html +='<div class="search-con-item">';
			html +='	<div class="search-con-item-title">适配车型</div>';
			html +='	<div class="dk-table product-info">';
			html +='	<table>';
			html +='	  <thead>';
			html +='		<th width="100px">品牌</th>';
			html +='		<th width="200px">车型</th>';
			html +='		<th width="200px">车型结构</th>';
			html +='		<th width="200px">排量(L)</th>';
			html +='		<th width="200px">发动机型号</th>';
			html +='		<th width="200px">功率（KW）</th>';
			html +='		<th width="200px">车型起始日期</th>';
			html +='		<th width="200px">车型停产日期</th>';
			html +='		<th width="200px">适配备注</th>';
			html +='		<th width="200px">适配变速箱类型</th>';
			html +='		<th width="200px">适配刹车盘备注</th>';
			html +='		<th width="200px">配件适用车型起始年份 &nbsp;&nbsp;</th>';
			html +='		<th width="200px"> &nbsp;&nbsp;&nbsp;&nbsp;配件适用车型截止年份</th>';
			html +='		<th width="200px">安装位置</th>';
			html +='	  </thead>';
			html +='	  <tbody>';
			if(vehicles){
				$(vehicles).each(function(idx,obj){
					trs +='<tr>'+
    				'<td>'+ (obj.BRAND_NAME || "")  +'</td>'+
                    '<td>'+ (obj.MODEL_NAME || "" )+'</td>'+
                    '<td>'+ (obj.FRAME_STRUCTURE || "") +'</td>'+
                    '<td>'+ (obj.DISPLACEMENT_L || "" )+'</td>'+
                    '<td>'+ (obj.ENGINE_NO || "" )+'</td>'+
                    '<td>'+ (obj.POWER_KW || "" )+'</td>'+
                    '<td>'+ com.utils().formatDateYYmm(obj.START_DATE)+'</td>'+
                    '<td>'+ com.utils().formatDateYYmm(obj.STOP_DATE)+'</td>'+
                    '<td>'+ (obj.spbz || "" )+'</td>'+
                    '<td>'+ (obj.spbsxlx || "" )+'</td>'+
                    '<td>'+ (obj.spscpbz || "" )+'</td>'+
                    '<td>'+ com.utils().formatDateYYmm(obj.pjsycxqsnf)+'</td>'+
                    '<td>'+ com.utils().formatDateYYmm(obj.pjsycxjznf)+'</td>'+
                    '<td>'+ (obj.azwz || "") +'</td>'+
                    '</tr>';
				});
			}else{
				trs = '<tr>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
	                    '<td>&nbsp;</td>'+
            	       '</tr>';
			}
			html += trs;
			html +='	  </tbody>';
			html +='	</table>';
			html +='	</div>';
			html +='</div>';
			$(container).append(html);
		},
		genpartInfo:function(data,container,callback){
			
			var html = "";
			html +='<div class="search-con-item">';
			html +='	<div class="search-con-item-title">零件信息</div>';
			html +='	<div class="dk-table product-info">';
			html +='		<table>';
			var headInfo = "<thead><th>零件号</th><th>零件名称</th><th>产品系列</th>";
			var bodyInfo = "<tbody>";
			var trs = "";
			var selObj = {};
			$(data).each(function(idx,obj){
				trs += "<tr tg='" + this.PART_NUMBER + "'>";
				trs += "<td>" + this.PART_NUMBER + "</td>";
				trs += "<td>" + this.PART_NAME_CN + "</td>";
				trs += "<td>" + this.prodLine + "</td>";
				if(idx == 0){
					$(this.name).each(function(idxj,obj){
						selObj[idxj] = [];
						selObj[idxj].push(obj);
					});
				}
				$(this.value).each(function(idxj,obj){
					selObj[idxj].push(obj);
					trs += "<td tg='" + idxj + "'>" + obj + "</td>";
				});
				trs +="</tr>";
			});
			//var idx = 0;
			for(var key in selObj){
				headInfo += "<th>";
				var thContent = "";
				var obj = selObj[key];
				obj = com.utils().uniqueArr(obj);
				var str= obj.shift();
				obj = com.utils().sortArr(obj);
				obj.unshift(str);
				$.each(obj,function(idx,obj){
					if(idx == 0){
						thContent += "<div class='combo'>" + obj + "<span class='caret'></span></div><ul tg='" + key + "' class='combo-items'><li class='combo-item'>全部</li>";	
					}else{
						thContent += "<li class='combo-item'>" + obj +"</li>";
					}
				});
				thContent += "</ul>";
				headInfo += thContent;
				headInfo += "</th>";
			}
			headInfo += "</thead>";
			bodyInfo += trs;
			bodyInfo += "</tbody>";
			html += headInfo;
			html += bodyInfo;
			html +='		</table>';
			html +='	</div>';
			html +='</div>';
			$(container).html(html);
			
			$(container).find(".combo").on("click",function(e){
				com.utils().pervent(e);
				if($(this).hasClass("active")){
					$(this).removeClass("active");
				}else{
					$(this).addClass("active");
					$(document).bind("click",function(){
						$(".combo").removeClass("active");
						$(document).unbind("click");
					});
				}
			});
			
			var condition = {};

			$(container).find(".combo-item").on("click",function(e){
				var tg = $(this).parent().attr("tg");
				condition[tg] = $(this).text();
				filterTb(condition);
				com.utils().pervent(e);
			});
			$(container).find(".combo-item").hover(function(){
				$(this).addClass("hover");
			},function(){
				$(this).removeClass("hover");
			});

			$(container).find("tbody").find("tr").on("click",function(){
				$(container).find("tbody").find("tr").removeClass("active");
				var tg = $(this).attr("tg");
				 $(this).addClass("active");
				if(callback){
					callback.call(null, tg);
				}
			});

			function filterTb(condition){
				$(container).find("tbody").find("tr").each(function(){
					var res = true;
					for(var key in  condition){
						var txt = $(this).find("td[tg='"+  key +"']").text();
						if(condition[key] != "全部"){
							if(condition[key] != txt){
								res = false;
								break;
							}
						}
					}
					if(res){
						$(this).show();
					}else{
						$(this).hide();
					}
				});
			}
		}
	};
}
if("function"==typeof define && define.amd && define){
	define(['jquery','common/pccommons'],function($,com){
		return ProdGener($,com);
	});
}

